package com.binge.spring.ioc.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;

/*
* 注册bean定义信息
* */
@Slf4j
public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        // registry.registerBeanDefinition();
        Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes("com.binge.spring.annotation.MyResource");
        String o = (String) annotationAttributes.get("value");
        log.info("value:{}", o);

        //扫描类
        MyScanner scanner = new MyScanner(registry);
        scanner.addIncludeFilter((metadataReader, metadataReaderFactory) -> true);
        scanner.scan(o);


    }
}
